package com.lwj.liwanjia.view.activity.work.shang_jia;

import android.support.v7.widget.LinearLayoutManager;
import android.support.v7.widget.RecyclerView;
import android.view.View;
import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.RelativeLayout;
import android.widget.TextView;
import android.widget.Toast;

import com.lwj.liwanjia.R;
import com.lwj.liwanjia.adapter.MaiJiaAdapter;
import com.lwj.liwanjia.base.BaseActivity;
import com.lwj.liwanjia.bean.MaiJiaBean;

import java.util.ArrayList;
import java.util.List;

/**
 * Created by 001 on 2017/9/13.
 */

public class MaiJiaHomeActivity extends BaseActivity implements View.OnClickListener {

    private TextView tv_back;
    private TextView tv_title;
    private ImageView iv_right;
    private MaiJiaAdapter homeAdapter;
    private List<MaiJiaBean> homeList;
    private RecyclerView mRecyclerView;

    @Override
    protected void initView() {

        tv_back = (TextView) findViewById(R.id.tv_left);
        tv_title = (TextView) findViewById(R.id.tv_title);
        iv_right = (ImageView) findViewById(R.id.iv_right);
        mRecyclerView = (RecyclerView) findViewById(R.id.recyclerView);

        tv_back.setVisibility(View.VISIBLE);
        tv_title.setVisibility(View.VISIBLE);
        tv_title.setText("卖家交流");
        iv_right.setImageResource(R.mipmap.xiaoxi);
        iv_right.setVisibility(View.VISIBLE);

        tv_back.setOnClickListener(this);
        iv_right.setOnClickListener(this);

    }

    @Override
    protected void initData() {

        //假数据 适配器
        initRecyclerView();
    }

    @Override
    protected int getLayoutId() {
        return R.layout.activity_mai_jia_home;
    }

    @Override
    public void onClick(View v) {
        switch (v.getId()) {
            //返回
            case R.id.tv_left:
                finish();
                break;
            //消息
            case R.id.iv_xiaoXi:
                Toast.makeText(MaiJiaHomeActivity.this, "消息", Toast.LENGTH_SHORT).show();
                break;
        }
    }

    //假数据 适配器
    private void initRecyclerView() {

        homeList = new ArrayList<>();

        for (int i = 0; i < 20; i++) {

            MaiJiaBean bean = new MaiJiaBean();
            bean.url = "http://tx.haiqq.com/uploads/allimg/141009/1429244325-55.jpg";
            homeList.add(bean);

            MaiJiaBean bean02 = new MaiJiaBean();
            bean02.url = "http://www.qqpk.cn/Article/UploadFiles/201010/20101002023556743.jpg";
            homeList.add(bean02);

            MaiJiaBean bean03 = new MaiJiaBean();
            bean03.url = "http://www.yh31.com/UploadFiles/Article3/PGRZN3/201012/201012261029169039.jpg";
            homeList.add(bean03);
        }

        LinearLayoutManager manager = new LinearLayoutManager(MaiJiaHomeActivity.this);
        mRecyclerView.setLayoutManager(manager);
        homeAdapter = new MaiJiaAdapter(MaiJiaHomeActivity.this, homeList);
        mRecyclerView.setAdapter(homeAdapter);
    }
}
